<?php

/************************Autoloading START***************************/
/********************************************************************/
// change this, if this code isn't "higher" than ALL classfiles
define("CLASS_DIR", dirname(__FILE__));

/**
 * autoload classes (no need to include them one by one)
 *
 * @uses classFolder()
 * @param $className string
 */
function __autoload($className) {
    $folder = classFolder($className);

    if($folder)
        require_once($folder.$className.".php");
}

/**
 * search for folders and subfolders with classes
 *
 * @param $className string
 * @param $sub string[optional]
 * @return string
 */
function classFolder($className, $sub = "/") {
    $dir = dir(CLASS_DIR.$sub);

    if(file_exists(CLASS_DIR.$sub.$className.".php"))
        return CLASS_DIR.$sub;

    while(false !== ($folder = $dir->read())) {
        if($folder != "." && $folder != "..") {
            if(is_dir(CLASS_DIR.$sub.$folder)) {
                $subFolder = classFolder($className, $sub.$folder."/");

                if($subFolder)
                    return $subFolder;
            }
        }
    }
    $dir->close();
    return false;
}
/************************Autoloading END******************************/
/********************************************************************/







$layout = './inc/normal_layout.php';
function render($data,$layout){           
    include $layout;   
}

mb_internal_encoding('UTF-8');




